<template>
	<view class="container">
		<view class="tips">
			<view>请选择您的身份</view>
			<view>为方便我们为您提供更准确的服务</view>
		</view>
		<view class="imgs">
			<image src="/static/boss.png" mode="aspectFill" @click="handleSelect(1)"></image>
			<image src="/static/staff.png" mode="aspectFill" @click="handleSelect(0)"></image>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		methods: {
			//选择用户身份0雇员1雇主
			async handleSelect(userType) {
				
				let res = await this.$fetch(this.$api.upd_user_type, {
					type: userType
				}, 'POST')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				uni.setStorageSync('userType', userType)
				this.setTabr(userType) // 根据用户状态更新不同的tabr
				uni.switchTab({ url: '/pages/index/index' })
				// uni.navigateTo({
				// 	url: '/pages/userifo-supplement/userifo-supplement',
				// })
				// if(userType == 1){
				// 	uni.switchTab({ url: '/pages/index/index' })
				// }else{
				// 	uni.switchTab({ url: '/pages/index/index' })
				// 	uni.navigateTo({
				// 		url: '/pages/userifo-supplement/userifo-supplement',
				// 	})
				// }
				
			},

			// 切换底部导航栏
			setTabr(userType) {
				if (userType == 1) {
					
					uni.hideTabBar()
				} else {
					uni.setTabBarItem({
						index: 0,
						text: '零工',
						"iconPath": "static/tab-bar/1.png",
						"selectedIconPath": "static/tab-bar/2.png",
					})
					uni.setTabBarItem({
						index: 1,
						text: '接单',
						"iconPath": "static/tab-bar/3.png",
						"selectedIconPath": "static/tab-bar/4.png",
					})
				}
			},
		}
	}
</script>

<style lang="less">
	.container {
		margin: 0 30rpx;

		.tips {
			margin: 50rpx 0;

			&>view:first-child {
				font-size: 22px;
				color: #402110;
				margin-bottom: 10rpx;
			}

			&>view:last-child {
				font-size: 14px;
				color: rgba(64, 33, 16, 0.70);
			}
		}

		.imgs {

			// display: flex;
			// align-items: center;
			// justify-content: center;
			image {
				width: 690rpx;
				height: 272rpx;
				background-color: #FFFFFF;
				margin-bottom: 30rpx;
			}
		}
	}
</style>
